<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%= fields_for :settings, OpenObject.new(settings) do |f| %>
  <table style="width: 500px;" class="formtable">
    <tr>
      <td colspan="2">
        <%= mt(:description, <<-TEXT)
This plugin allows final grades to be published back to a student information system (SIS).  When enabled, the user will be given an option in the gradebook to publish these grades.  This will occur via a POST request to the specified publish endpoint.  Each type defines it's own content format and mime type.  The response from the endpoint does not matter and is currently ignored.

For example, the Instructure formatted CSV will POST a csv file with mime type 'text/csv' to the specified endpoint, containing the following columns:

"publisher_id", "publisher_sis_id", "course_id", "course_sis_id", "section_id", "section_sis_id", "student_id", "student_sis_id", "enrollment_id", "enrollment_status", "score", "grade"

(Note: the "grade" column is only returned if the course specifies a grading standard)

For each student in the course being published, there will be 1 or more rows in the published csv. Specifically, there will be 1 row for each login that the student has in the course's root account.  Most of the time this will result in 1 row per student, but if the student has multiple logins, there will be a row for each of them.
TEXT
        %>
      </td>
    </tr>
    <tr>
      <td><%= f.blabel :format_type, :en => "Output format type" %></td>
      <td><%= f.select :format_type, Course.valid_grade_export_types.keys.map{|k| [Course.valid_grade_export_types[k][:name], k]}, {} %>
    </tr>
    <tr>
      <td><%= f.blabel :publish_endpoint, :en => "Endpoint to publish to" %></td>
      <td><%= f.text_field :publish_endpoint %></td>
    </tr>
    <tr>
      <td colspan=2><%= f.check_box :wait_for_success, {}, 'yes', 'no' %>
      <%= f.label :wait_for_success, :en => "Wait for success notifications" %></td>
    </tr>
    <tr>
      <td><%= f.blabel :success_timeout, :en => "Success notification timeout (in seconds)" %></td>
      <td><%= f.text_field :success_timeout %></td>
    </tr>
  </table>
<% end %>
